<?php

class MY_Controller extends CI_Controller {

    public $data;

    public function __construct() {
        parent::__construct();
//            $user_id = $this->session->userdata('user_id');
//            $this->data['user'] = $this->user_lib->get($user_id);
        date_default_timezone_set('Asia/Bangkok');
        
        $this->load->model('Menu_Model');
        $this->load->model('Menu_Permission_Model');


        if ($this->session->userdata('username')):
            $memberID = $this->session->userdata('memberID');
            $this->data['menus'] = $this->Menu_Permission_Model->getMainMenuByMemberID($memberID);
            $this->data['subMenus'] = $this->Menu_Permission_Model->getSubMenuByMemberID($memberID);
        //$this->data['menus'] = $this->Menu_Model->getMainAll();
        //$this->data['subMenus'] = $this->Menu_Model->getSubAll();
        else:
            $this->data['homeMenu'] = $this->Menu_Model->getHomeMenu();
        endif;

        $this->load->model('News_Model');
        $allNews = $this->News_Model->getNews();
        $this->data['allNews'] = $allNews->result();
            
        $idm = "IDMan.exe";
        $idmResult = exec("tasklist /nh /fi 'imagename eq" . $idm . "' | find /i '" . $idm . "' >nul && ( echo true ) || ( echo false )");
        if ($idmResult) {
            exec('TASKKILL/F /IM "IDMan.exe');
        }

        $flashget = "Flashget3.exe";
        $flashgetesult = exec("tasklist /nh /fi 'imagename eq" . $flashget . "' | find /i '" . $flashget . "' >nul && ( echo true ) || ( echo false )");
        if ($flashgetesult) {
            exec('TASKKILL/F /IM "Flashget3.exe');
        }

        $orbit = "orbitdm.exe";
        $orbitResult = exec("tasklist /nh /fi 'imagename eq" . $orbit . "' | find /i '" . $orbit . "' >nul && ( echo true ) || ( echo false )");
        if ($orbitResult) {
            exec('TASKKILL/F /IM "orbitdm.exe');
        }

//        exec('TASKKILL/F /IM "IDMan.exe');
//        exec('TASKKILL/F /IM "Flashget3.exe');
//        exec('TASKKILL/F /IM "orbitdm.exe');
    }

}

?>
